package com.ly.aidlpratice.bean;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import org.jetbrains.annotations.NotNull;

/**
 * Created by Lan Yang on 2021/6/1
 */
public class Book implements Parcelable {
    private String mName;
    private int mCode;
    private float mPrice;

    public Book(String name, int code, float price) {
        this.mName = name;
        this.mCode = code;
        this.mPrice = price;
    }

    protected Book(Parcel in) {
        mName = in.readString();
        mCode = in.readInt();
        mPrice = in.readFloat();
    }

    public static final Creator<Book> CREATOR = new Creator<Book>() {
        @Override
        public Book createFromParcel(Parcel in) {
            return new Book(in);
        }

        @Override
        public Book[] newArray(int size) {
            return new Book[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mName);
        dest.writeInt(mCode);
        dest.writeFloat(mPrice);
    }

    public String getName() {
        return mName;
    }

    public void setName(String name) {
        this.mName = name;
    }

    public int getCode() {
        return mCode;
    }

    public void setCode(int code) {
        this.mCode = code;
    }

    public float getPrice() {
        return mPrice;
    }

    public void setPrice(float price) {
        this.mPrice = price;
    }

    @NonNull
    @NotNull
    @Override
    public String toString() {
        return "[ name=" + mName + " code=" + mCode + " price=" + mPrice + " ]";
    }
}